package com.example.doctor.service;
import com.alibaba.dubbo.config.annotation.Service;
import com.example.mapper.GdArticleMapper;
import com.example.mapper.GdCommentMapper;
import com.example.mapper.GdInfoDicMapper;
import com.example.pojo.GdArticle;
import com.example.pojo.GdArticleWithBLOBs;
import com.example.pojo.GdInfoDic;
import com.example.service.RpcAtileService;
import com.example.vo.ArticleVO;
import com.example.vo.DeptInfoVo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by LENOVO on 2018/9/27.
 */
@Component
@Service(interfaceClass = RpcAtileService.class)
public class RpcAtileServiceImpl implements RpcAtileService{

    @Resource
    private GdInfoDicMapper gdInfoDicMapper;

    @Resource
    private GdArticleMapper gdArticleMapper;
    @Override
    public List<GdInfoDic> getArticleType(Map map) throws Exception {
        return gdInfoDicMapper.selectArticleType(map);
    }

    @Override
    public List<GdArticleWithBLOBs> getArticleList(ArticleVO articleVO) throws Exception {
        Map map=new HashMap<String,Object>();
        List<DeptInfoVo> deptInfoVoList=  new ArrayList<DeptInfoVo>();
        map.put("categorylevel1",articleVO.getCategorylevel1());
        map.put("categorylevel2",articleVO.getCategorylevel2());
        return gdArticleMapper.selectArticleList(map);
    }

    @Override
    public GdArticleWithBLOBs getArticleDetleById(Long id) {

        GdArticleWithBLOBs gdArticleWithBLOBs= gdArticleMapper.selectByPrimaryKey(id);
        GdArticleWithBLOBs gdArticleWithBLOBs1=new GdArticleWithBLOBs();
        gdArticleWithBLOBs1.setId(id);
        gdArticleWithBLOBs1.setReadnumber(gdArticleWithBLOBs.getReadnumber()+1);
        gdArticleMapper.updateByPrimaryKeySelective(gdArticleWithBLOBs1);
        return gdArticleWithBLOBs;
    }

}
